<!DOCTYPE html>
<html lang="en" style="height: 100%;overflow:hidden;">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>JAVA代码生成工具2.0</title>
    <link rel="stylesheet" type="text/css" href="../css/common/element-ui.css">
    <link rel="stylesheet" type="text/css" href="../css/code.css">
    <script src="../js/common/axios.min.js"></script>
    <script src="../js/common/vue2.js"></script>
    <script src="../js/common/element-ui.js"></script>
    <script src="../js/base-utils.js"></script>
    <style>
        .el-scope-shape {
            background: #FFFFFF;
            margin: 10px;
            /*box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);*/
            box-shadow: 0 2px 4px rgba(0,0,0,.12), 0 0 6px rgba(0,0,0,.04);
            border-radius: 5px;
        }
        .el-button--mini { margin: 1px;padding: 5px; }
        .el-input-inner-a .el-input__inner { border: 1px solid #D8BFD8; }
        .des-label-class { height: 55px; width: 200px; }
    </style>
</head>
<body style="background: #f5f5f5">
<div id="app">

    <el-container style="height: 700px" v-loading="loading.download">
        <el-aside v-loading="loading.tree" width="35%" style="height: 700px">
            <el-header class="el-scope-shape" align="center">
                <el-input placeholder="搜索数据源..." v-model="treeFilter" style="width: 40%" size="small" class="el-input-inner-a"></el-input>
                <el-input placeholder="搜索表名..." v-model="tableFilter" style="width: 40%" size="small" class="el-input-inner-a" @keyup.enter.native="tableSearchList"></el-input>
                <el-button size="small" type="primary" icon="el-icon-download" @click="downloadFile">生成</el-button>
            </el-header>

            <div class="el-scope-shape" style="overflow:auto; height: 600px">
                <el-tree
                        class="filter-tree"
                        :data="treeData"
                        :props="defaultProps"
                        :default-expanded-keys="[0]"
                        :filter-node-method="filterNode"
                        highlight-current
                        @node-click="selectedNode"
                        @node-contextmenu="rightClickNode"
                        node-key="id"
                        ref="tree" style="padding: 3px">
                    <template #default="{ node,data }">
                        <div style="width: 100%">
                            <span style="float: left" :class="data.id == 0 ? 'label-class' : ''">
                                <span v-if="data.id != 0" :class="getTagClass(data)">{{ data.tag }}</span>
                                {{ data.label }}
                                <el-badge v-if="data.children && data.children.length > 0" :value="data.children.length" class="item" type="danger" :max="99"></el-badge>
                            </span>
                            <el-button v-if="data.id == 0" style="float: right" class="el-bu-success" type="success" @click="addNode(data)" icon="el-icon-plus" size="mini"></el-button>
                            <el-button v-if="data.id != 0" style="float: right" class="el-bu-delete" type="danger" @click="delNode(data)" icon="el-icon-delete" size="mini"></el-button>
                            <el-button v-if="data.id != 0" style="float: right" class="el-bu-primary" type="primary" @click="editNode(data)" icon="el-icon-edit" size="mini"></el-button>
                        </div>
                    </template>
                </el-tree>
            </div>
        </el-aside>


        <el-main style="height: 670px;padding: 0px" class="el-scope-shape">
            <el-menu default-active="tab" @select="menuSelect" active-text-color="#409eff" mode="horizontal" style="padding: 3px">
                <el-menu-item v-for="menu in menuList" :key="menu.index" :index="menu.index">{{ menu.name }}</el-menu-item>
            </el-menu>
            <div style="height: 595px;padding: 3px" v-if="openMenu.tab">
                <el-table height="94%" size="mini"
                          v-loading="loading.table"
                          @row-click="tableRowClick"
                          @selection-change="tableSelection"
                          :data="tableList"
                          border stripe fit ref="table"
                          :header-cell-style="{ borderRadius:'5px', background:'#c6e2ff', color:'#000000' }">
                    <el-table-column type="selection" width="50" align="center"></el-table-column>

                    <el-table-column label="名 称" align="center">
                        <template slot-scope="scope">{{ scope.row.tableName }}</template>
                    </el-table-column>

                    <el-table-column label="注 释" align="center">
                        <template slot-scope="scope">{{ scope.row.tableComment }}</template>
                    </el-table-column>
                </el-table>
                <div align="center">
                    <el-pagination background
                                   :current-page="tablePage.currentPage"
                                   :page-size="tablePage.pageSize"
                                   :total="tablePage.totalCount"
                                   @size-change="tablePageSize"
                                   @current-change="tableCurrentPage"
                                   :page-sizes="[15, 50, 100, 200]"
                                   layout="total, sizes, prev, pager, next, jumper">
                    </el-pagination>
                </div>
            </div>

            <div style="height: 595px;padding: 3px" v-if="openMenu.strategy">
                <el-descriptions :column="2" border size="mini">
                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-open"></i> Lombok</template>
                        <el-switch v-model="currStrategy.enableLombok" active-color="#13ce66"
                                   inactive-color="#ff4949" :active-value="true" :inactive-value="false">
                        </el-switch>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-guide"></i> parents包名</template>
                        <el-input v-model="currStrategy.parentPath" placeholder="默认值: com"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-open"></i> Swagger</template>
                        <el-switch v-model="currStrategy.enableSwagger" active-color="#13ce66"
                                   inactive-color="#ff4949" :active-value="true" :inactive-value="false">
                        </el-switch>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-guide"></i> Entity包名</template>
                        <el-input v-model="currStrategy.entityPack" placeholder="默认值: entity"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-open"></i> Boolean忽略is</template>
                        <el-switch v-model="currStrategy.ignoreBooleanPrefix" active-color="#13ce66"
                                   inactive-color="#ff4949" :active-value="true" :inactive-value="false">
                        </el-switch>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-guide"></i> Service包名</template>
                        <el-input v-model="currStrategy.servicePack" placeholder="默认值: service"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-discount"></i> 乐观锁</template>
                        <el-input v-model="currStrategy.versionColumnName" placeholder="默认值: revision"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-guide"></i> ServiceImpl包名</template>
                        <el-input v-model="currStrategy.serviceImplPack" placeholder="默认值: service.impl"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-user"></i> 创建人</template>
                        <el-input v-model="currStrategy.author" placeholder="默认值: Author"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-copy-document"></i> ServiceImpl父类</template>
                        <el-input v-model="currStrategy.superServiceImplClass" placeholder="如: com.service.BaseService"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-discount"></i> 逻辑删除</template>
                        <el-input v-model="currStrategy.logicDeleteColumnName" placeholder="默认值: del_flag"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-guide"></i> Mapper包名</template>
                        <el-input v-model="currStrategy.mapperPack" placeholder="默认值: mapper"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-eleme"></i> 忽略表名前缀</template>
                        <el-input v-model="currStrategy.ignoreTablePrefixs" placeholder="忽略表名前缀(','号分隔)"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-copy-document"></i> Mapper父类</template>
                        <el-input v-model="currStrategy.superMapperClass" placeholder="如: com.mybatis.ProBaseMapper"></el-input>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label"><i class="el-icon-s-finance"></i> 自动填充
                            <el-button type="text" @click="open.fill = true">( 打开 )</el-button>
                        </template>
                        <el-tag v-for="f in fillDsList" :key="f.id" @close="fillDsDel(f)" closable style="margin-right: 3px">
                            {{ f.columnName }} | {{ f.fieldFillType }}
                        </el-tag>
                    </el-descriptions-item>
                </el-descriptions>
                <div align="center">
                    <el-button type="primary" @click="strategySave" style="margin-top: 3px">保存</el-button>
                </div>
            </div>
        </el-main>
    </el-container>



    <el-dialog :visible.sync="open.fill" :close-on-click-modal="false" title="自动填充列表" width="35%" top="20vh" align="center">
        <el-input placeholder="列 名" v-model="currStrategy.columnName" style="width: 200px" @keyup.enter.native="fillSave" size="small"></el-input>
        <el-select v-model="currStrategy.fieldFillType" placeholder="填充类型" size="small" style="width: 200px">
            <el-option label="DEFAULT" value="DEFAULT"></el-option>
            <el-option label="INSERT" value="INSERT"></el-option>
            <el-option label="UPDATE" value="UPDATE"></el-option>
            <el-option label="INSERT_UPDATE" value="INSERT_UPDATE"></el-option>
        </el-select>
        <el-button size="small" type="primary" @click="fillSave">添加</el-button>
        <el-button size="small" type="primary" @click="fillDsSave" style="margin-left: 0px">确定</el-button>

        <el-table height="330" size="mini"
                  @selection-change="fillSelection"
                  @row-click="fillRowClick"
                  :data="fillList"
                  border stripe fit ref="fill"
                  style="margin-top: 3px">
            <el-table-column type="selection" width="50" align="center"></el-table-column>

            <el-table-column label="列 名" align="center" show-overflow-tooltip>
                <template slot-scope="scope">{{ scope.row.columnName }}</template>
            </el-table-column>

            <el-table-column label="填充类型" align="center" show-overflow-tooltip>
                <template slot-scope="scope">{{ scope.row.fieldFillType }}</template>
            </el-table-column>

            <el-table-column label="操 作" align="center" width="70" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-tag class="tag-delete" type="danger" @click="fillDsDel(scope.row)">删除</el-tag>
                </template>
            </el-table-column>
        </el-table>
    </el-dialog>

    <el-dialog :visible.sync="open.datasource" :close-on-click-modal="false" title="数据源" width="50%" align="center" top="9vh">
        <el-descriptions class="margin-top" :column="1" border size="mini">
            <el-descriptions-item>
                <template slot="label"><i class="el-icon-open"></i> 名称</template>
                <el-input v-model="currDatasource.dbName" placeholder="请输入配置名称..." maxlength="50" show-word-limit></el-input>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label"><i class="el-icon-open"></i> 类型</template>
                <div align="left">
                    <el-radio v-model="currDatasource.dataType" label="mysql" border>MYSQL</el-radio>
                    <el-radio v-model="currDatasource.dataType" label="oracle" border>ORACLE</el-radio>
                    <el-radio v-model="currDatasource.dataType" label="db2" border>DB2</el-radio>
                    <el-radio v-model="currDatasource.dataType" label="kingbase8" border>KING_BASE8</el-radio>
                </div>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label"><i class="el-icon-open"></i> 地址
                    <el-button type="text" @click="open.example = true">( 示例 )</el-button>
                </template>
                <el-input type="text" v-model="currDatasource.url" placeholder="详情请查看左边的示例..."></el-input>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label"><i class="el-icon-open"></i> 库名/表空间</template>
                <el-input v-model="currDatasource.libraryName" placeholder="请输入库名/表空间"></el-input>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label"><i class="el-icon-open"></i> 账号</template>
                <el-input v-model="currDatasource.username" placeholder="请输入账号..."></el-input>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label"><i class="el-icon-open"></i> 密码</template>
                <el-input v-model="currDatasource.password" show-password placeholder="请输入密码..."></el-input>
            </el-descriptions-item>
        </el-descriptions>
        <el-button type="primary" icon="el-icon-upload" @click="saveNode" style="margin-top: 3px">保存</el-button>
    </el-dialog>

    <el-dialog :visible.sync="open.example" :close-on-click-modal="false" title="url示例" width="40%" align="center">
        <el-descriptions :column="1" border size="mini">
            <el-descriptions-item>
                <template slot="label">MYSQL</template>
                <el-input type="text" v-model="example.mysql"></el-input>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">ORACLE</template>
                <el-input type="text" v-model="example.oracle"></el-input>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">DB2</template>
                <el-input type="text" v-model="example.db2"></el-input>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">KING</template>
                <el-input type="text" v-model="example.king"></el-input>
            </el-descriptions-item>
        </el-descriptions>
    </el-dialog>

    <div id="contextmenu" v-show="open.menu" class="menu">
        <el-button @click="copyNode" style="width: 100%;line-height: 2px">复制</el-button>
    </div>
</div>
</body>
<script src="../js/code.js"></script>
</html>